package com.svse.activemq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Queue;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Copyright 上海危网信息科技有限公司版权所有
 * @company wwsoft
 * @Date 2020/4/10 8:54
 */
@Component
public class JmsComponent {
    @Autowired
    private   JmsMessagingTemplate jmsMessagingTemplate;
    @Autowired
    private Queue queue;

    public  void  send(MessagePojo messagePojo){
        jmsMessagingTemplate.convertAndSend(this.queue,messagePojo);
    }

    @JmsListener(destination = "hello.javaLyh")
    public void receive(MessagePojo messagePojo){
        System.out.println(messagePojo.toString());
    }
}
